package com.sg.service.impl;

import com.sg.dao.BaseDAO;
import com.sg.model.Userif;
import com.sg.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.hibernate.query.Query;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service("userService")
public class UserServiceImpl implements UserService {

    @Autowired
    private BaseDAO<Userif> baseDAO;

    public List<Userif> findAll() {
        return baseDAO.findAll(Userif.class);
    }

    public List<Userif> findByUsername(String username) {
        String hql=" from Userif where username=:username";
        Map<String,Object> map = new HashMap<String,Object>();
        map.put("username", username);
        Query query =	baseDAO.getHqlQuery(hql, map);

        return query.list();
    }

    public void mergeItem(Userif user) {
        baseDAO.mergeItem(user);
    }
}
